package com.mck.entity;

import lombok.Data;

/**
 * 后端返回结果
 */
@Data
public class Result {

    private Integer code; // 返回码 0,1
    private String msg; // 返回信息
    private Object data; // 返回数据

    // 成功
    public static Result success() {
        Result result = new Result();
        result.code = 1;
        result.msg = "success";
        return result;
    }

    // 成功且返回数据
    public static Result success(Object data) {
        Result result = success();
        result.data = data;
        return result;
    }

    // 失败
    public static Result error(String msg) {
        Result result = new Result();
        result.code = 0;
        result.msg = msg;
        return result;
    }
}
